import singleton from "@/util/singleton"

class Timeout {
	#fun = null;

	add(callback, time = 60) {
		time = time * 1000
		console.log('执行定时器')
		this.fun = setTimeout(() => {
			if (typeof callback === 'function') {
				callback()
			}
		}, time)
	}

	clear() {
		console.log('清除定时器', this.fun)
		if(this.fun) {
			clearTimeout(this.fun)
		}
	}


}

export default singleton(Timeout)